对学生信息进行基本的增删改查,动态添加listview,单击表头对获取的数据进行排序,表的连接以及模糊查找有任何问题联系邮箱jery1997@foxmail.com
Info_studentlv.Items.Clear();
try
{
string str = string.Format("select * from frm_Student ");
DataTable dt = DataWork1.DataQuery(str);
Info_studentlv.ColumnClick = new ColumnClickEventHandler(Info_studentlv_ColumnClick);
Info_studentlv.ContextMenuStrip = Info_Student;
Info_studentlv.Dock = DockStyle.Fill;
Info_studentlv.FullRowSelect = true;
Info_studentlv.View = View.Details;
if (cishu1 == 0)
{
Info_studentlv.Columns.Add("num", "学号");
Info_studentlv.Columns.Add("姓名");
Info_studentlv.Columns.Add("专业号");
Info_studentlv.Columns.Add("班级号");
Info_studentlv.Columns.Add("Tel", "电话");
Info_studentlv.Columns.Add("性别");
Info_studentlv.Columns.Add("Address", "家庭住址");
Info_studentlv.Columns.Add("ID", "身份证");
Info_studentlv.Columns.Add("入学时间");
Info_studentlv.Columns.Add("出生时间");
Info_studentlv.Columns.Add("宿舍号");
Info_studentlv.Columns.Add("毕业时间");
Info_studentlv.Columns["Tel"].Width = -2;
Info_studentlv.Columns["Address"].Width = -2;
Info_studentlv.Columns["ID"].Width = -2;
Info_studentlv.Columns["num"].Width = -2;
}
foreach (DataRow dr in dt.Rows)
{
ListViewItem myitem = new ListViewItem(dr["No_Student"].ToString() " ");
myitem.SubItems.Add(dr["Name"].ToString());
myitem.SubItems.Add(dr["No_Major"].ToString());
myitem.SubItems.Add(dr["No_Class"].ToString());
myitem.SubItems.Add(dr["Tel"].ToString());
if (dr["Sex"].ToString() == "True")
{
myitem.SubItems.Add("男");
}
else
{
myitem.SubItems.Add("女");
}
myitem.SubItems.Add(dr["Address"].ToString());
myitem.SubItems.Add(dr["ID"].ToString());
myitem.SubItems.Add(dr["Time_In"].ToString());
myitem.SubItems.Add(dr["Time_On"].ToString());
myitem.SubItems.Add(dr["No_home"].ToString());
myitem.SubItems.Add(dr["Time_G"].ToString());
Info_studentlv.Items.Add(myitem);
}
if (cishu1 == 0 || TabControl1.TabPages.Count == 0)
{
SkinTabPage Page = new SkinTabPage();
// Page.Name = "Page" ;
Page.Text = skinButton1.Text;
Info_studentlv.Parent = Page;
this.TabControl1.Controls.Add(Page);
this.TabControl1.SelectedIndex = TabControl1.TabPages.Count - 1;
cishu1 = 1;
}
}
catch (Exception)
{
CusterFormControl("异常提示!", "1.SQL服务未开启\r\n2.数据库连接错误!", "请检查后重试", "", "");
}
评论